home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 43 / Amiga Format CD43 (1999)(Future Publishing)(GB)(Track 1 of 2)[!][issue 1999-09].iso / -serious- / wb / backclock / sources / partial.c < prev    next >
C/C++ Source or Header  |  1999-06-15  |  4KB  |  140 lines

  1. /*****************************************************************************
  2.  * 
  3.  * name                    : partial.c
  4.  * description            : close & reopen window on workbench close
  5.  * version                : 2.1ß2
  6.  *
  7.  * created                : ?
  8.  * last change            : 14-07-98
  9.  *
  10.  * version 2.1: bugfixed (sizing and dragging gadget)
  11.  * version 2.1ß2 : now open the window as backdrop (working)
  12.  *
  13.  *****************************************************************************
  14.  */
  15. #include "utils.h"
  16. #include "partial.h"
  17. #include "obp.h"
  18. #include <proto/intuition.h>
  19. #include <proto/exec.h>
  20.  
  21.  
  22. BOOL partialClose(idWin * prj) {
  23.   /* 
  24.    * handle notify_intuition msg
  25.    * close the window 
  26.    * 
  27.    */
  28.   BOOL ret = FALSE ;
  29.   struct Message * msg ;
  30.   struct IntNotifyMessage * imsg ;
  31.   
  32.   msg = GetMsg(prj->notifyPort) ;
  33.   imsg = (struct IntNotifyMessage*)msg ;
  34.  
  35.   if (imsg->inm_Code == 0x200) {
  36.     /* close the window
  37.      */
  38.     if (prj->win) {  
  39.       CloseWindow(prj->win) ;
  40.       prj->win = NULL ;      // in case of error
  41.       ret = TRUE ;
  42.     }
  43.   }
  44.   if (msg) ReplyMsg(msg) ;
  45.   
  46.   return(ret) ;
  47. }
  48.  
  49.  
  50. void partialOpen(idWin * prj) {
  51.   /* reopen the window
  52.    */
  53.   struct Screen * WBScreen = NULL ;
  54.   struct Message * msg ;
  55.   struct IntNotifyMessage * imsg ;
  56.   UWORD code ;
  57.   ULONG mask ;
  58.   
  59.   do{
  60.     /* get msg from notifyintuition
  61.      */
  62.     mask = Wait(1<<(prj->notifyPort->mp_SigBit)) ;
  63.     if ((msg = GetMsg(prj->notifyPort)) != NULL) {
  64.       /* received a msg
  65.        */
  66.       imsg = (struct IntNotifyMessage *)msg ;
  67.       code = imsg->inm_Code ;
  68.       ReplyMsg(msg) ;
  69.     }
  70.   }while(code != 0x100) ;
  71.    
  72.   WBScreen = LockPubScreen("Workbench") ;
  73.   prj->wb = WBScreen ;
  74.   free_bitmap(prj) ;
  75.   init_bitmap(prj) ;
  76.   prj->win = OpenWindowTags(NULL, WA_Left,    prj->backWin.posX,
  77.                                              WA_Top,        prj->backWin.posY,
  78.                                              WA_Width,    prj->backWin.width,
  79.                                              WA_Height,    prj->backWin.height,
  80.                                              WA_IDCMP,    IDCMP,
  81.                                  WA_MinWidth,     50,
  82.                                  WA_MinHeight,   50,
  83.                                  WA_MaxHeight,   200,
  84.                                  WA_MaxWidth,    200, 
  85.                                              WA_Flags,    WFLG,
  86.                                              WA_ScreenTitle, TXT_SCRTITLE, 
  87.                                              WA_NewLookMenus, TRUE,
  88.                                              WA_PubScreenName, "Workbench", TAG_DONE) ;
  89.   RemoveGList(prj->win, &szgdg, 2) ;
  90.                                              
  91.   szgdg.Width  = prj->win->Width ;
  92.   szgdg.NextGadget = &tagdg ;
  93.   tagdg.LeftEdge  = prj->win->Width - 10 ;
  94.   tagdg.TopEdge   = prj->win->Height - 10 ;
  95.   
  96.   AddGList(prj->win, &szgdg, 0, 2, NULL) ;
  97.    
  98.   RefreshGList(&szgdg, prj->win, NULL, -1) ;                                                           
  99.   UnlockPubScreen(NULL, WBScreen) ;
  100.   setColors(prj) ;
  101. }
  102.  
  103.  
  104. void setWindow(idWin * prj) {
  105.   CloseWindow(prj->win) ;
  106.   prj->wb = LockPubScreen("Workbench") ;
  107.   
  108.   free_bitmap(prj) ;
  109.   init_bitmap(prj) ;
  110.   
  111.   prj->win = OpenWindowTags(NULL, WA_Left,    prj->backWin.posX,
  112.                                              WA_Top,        prj->backWin.posY,
  113.                                              WA_Width,    prj->backWin.width,
  114.                                              WA_Height,    prj->backWin.height,
  115.                                              WA_IDCMP,    IDCMP,
  116.                                  WA_MinWidth,     50,
  117.                                  WA_MinHeight,   50,
  118.                                  WA_MaxHeight,   MAXH,
  119.                                  WA_MaxWidth,    MAXH, 
  120.                                              WA_Flags,    WFLG,
  121.                                              WA_ScreenTitle, TXT_SCRTITLE, 
  122.                                              WA_NewLookMenus, TRUE,
  123.                                              WA_PubScreenName, "Workbench", TAG_DONE) ;
  124.   RemoveGList(prj->win, &szgdg, 2) ;
  125.                                              
  126.   szgdg.Width  = prj->win->Width ;
  127.   szgdg.NextGadget = &tagdg ;
  128.   tagdg.LeftEdge  = prj->win->Width /2 ;
  129.   tagdg.TopEdge   = prj->win->Height - 20 ;
  130.   tagdg.Width     = prj->win->Width /2 ;
  131.   
  132.   AddGList(prj->win, &szgdg, 0, 2, NULL) ;
  133.    
  134.   RefreshGList(&szgdg, prj->win, NULL, -1) ;
  135.  
  136.   UnlockPubScreen(NULL, prj->wb) ; 
  137. //  ChangeWindowBox(prj->win, prj->backWin.posX, prj->backWin.posY, prj->backWin.width, prj->backWin.height) ;
  138.   reinit_win(prj) ;
  139. }
  140.